package com.old.controller;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.old.result.PageBean;
import com.old.result.Result;


import com.old.service.impl.Recommendationservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/recommend")
public class RecommendationController {

    @Autowired
    private Recommendationservice recommendationService;

    @GetMapping("/posts")
    public Result<PageBean> getRecommendations(
          @RequestParam(defaultValue = "1") Integer pageNo,
          @RequestParam(defaultValue = "5") Integer pageSize,
          @RequestParam (required = false)Integer sortBy,
          @RequestParam (required = false)Integer userId,
          @RequestParam (required = false)String searchTerms) throws JsonProcessingException {

        return Result.success(
                recommendationService.getRecommendedPosts(pageNo,pageSize, sortBy,searchTerms,userId)
        );
    }
}
